home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.cyberramp.net!news
- From: sinan@cyberramp.net (John Noland)
- Newsgroups: comp.lang.c
- Subject: Re: Help With Pointers
- Date: 22 Feb 1996 05:42:18 GMT
- Organization: Prose Software
- Message-ID: <4ggvnq$2bt@newshost.cyberramp.net>
- References: <4g67cj$6cv@hobbes.compusult.nf.ca>
- NNTP-Posting-Host: ramp1-27.cyberramp.net
- X-Newsreader: WinVN 0.99.5
-
- In article <4g67cj$6cv@hobbes.compusult.nf.ca>, bryan@public.compusult.nf.ca says...
- >
- >Hi
- >
- >Is there any way to assign a char pointer to a float pointer?
- >
- >I had to do some byte rotation on binary data. I rotated
- >the characters and know want to point a float at the first
- >character position to read back a 4 byte float.
- >
- >I'am actually trying to read SGI binary data with a PC. I've been told
- >that the SGI bytes ( not bits ) are rotated versus a PC. Any help
- >would be appreciated. Are the bytes rotated?
- >
-
- Have you tried this approach and failed? I suspect that you haven't tried
- it. You can have a pointer of type char and a pointer of type float pointing
- to the same place. I might get chastised by the gurus for this, but you
- know what? I don't care. You might try just a simple union as your destination
- variable. So, you might wind up with something like this;
-
- char SGI_source[4];
- union {
- char d1[4];
- float d2;
- } dest;
-
- dest.d1[1] = SGI_source[2];
- dest.d2[2] = SGI_source[1];
-
- or however the byte rotation needs to be done.
-
- -John
-
-